#include <iostream>
#include <memory>
#include <string>

using namespace std;

/*
\ brief:  策略接口对象
\ author: 清晨与猫鱼
*/
class Strategy {
public:
    virtual int doOperation(int, int) = 0;
};


/*
\ brief:  加法操作
\ author: 清晨与猫鱼
*/
class OperationAdd 
    : public Strategy {
public:
    int doOperation(int num1, int num2) {
        return num1 + num2;
    }
};


/*
\ brief:   减法操作
\ author: 清晨与猫鱼
*/
class OperationSubstract 
    : public Strategy {
public:
    int doOperation(int num1, int num2) {
        return num1 - num2;
    }
};

/*
\ brief:  乘法操作
\ author: 清晨与猫鱼
*/
class OperationMultiply 
    : public Strategy {
public:
    int doOperation(int num1, int num2) {
        return num1 * num2;
    }
};


/*
\ brief:   上下文
\ author: 清晨与猫鱼
*/
class Context {
public:
    explicit Context()
        : strategy_(nullptr) {             
    }

    explicit Context(Strategy* strategy)
        : strategy_(strategy) {            
    }

    void setStrategy(Strategy* strategy) {
        strategy_ = strategy;
    }

/*
\ brief:  执行策略
\ author: 清晨与猫鱼
*/
    int executeStrategy(int num1, int num2) {
        return strategy_->doOperation(num1, num2);
    }
private:
    Strategy* strategy_;        // 策略引用
};

